package com.etlmaster.executor.steps.datax;

import java.util.HashMap;
import java.util.Map;

import com.etlmaster.core.DataSourceDefine;
import com.etlmaster.core.DataSourceHolder;
import com.etlmaster.executor.Step;
import com.etlmaster.executor.StepMeta;
import com.etlmaster.executor.annotation.StepInstruction;
import com.etlmaster.executor.utils.DataCollectionUtils;

/**
 * @author Wugf
 * @date 2016-03-08
 */
@StepInstruction("hivereader")
public class HiveReaderStep extends Step {
	private HiveReaderStepMeta meta;
	public HiveReaderStep(StepMeta meta) {
		super(meta);
		this.meta=(HiveReaderStepMeta)meta;
		// TODO Auto-generated constructor stub
	}

	@Override
	protected int handle() {
		
		DataSourceDefine def = DataSourceHolder.getInstance()
				.getDataSourceDefine(meta.getDsName());

		Map<String, String> data = new HashMap<String, String>();
		data.put("url", def.getUrl());
		data.put("username",def.getUsername());
		data.put("password",def.getPassword());
		data.put("readMode", meta.getReadMode());
		data.put("sql", meta.getSql());
		data.put("dataDir", DataCollectionUtils.getProperties("tempDatxHdfsDir"));
		data.put("reduceNumber", meta.getReduceNumber());
		data.put("concurrency", meta.getConcurrency());
		
		return DataxReader.runDataxReader(this.hashCode(), meta.getPluginName(), data, meta);
	}

	@Override
	public boolean stop() {
		// TODO Auto-generated method stub
		return false;
	}



}
